package com.gxa.controller;

import com.gxa.common.LayR;
import com.gxa.common.R;
import com.gxa.param.NoticeParam;

import com.gxa.pojo.Notice;
import com.gxa.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private NoticeService service;
    @GetMapping("/list/page")
    public String list(){
        return "notice/notice_list";
    }

    @PostMapping("/list/data")
    @ResponseBody
    public LayR listData(NoticeParam param){
        return service.list(param);
    }

    @GetMapping("/add/page")
    public String addPage(){
        return "notice/notice_add";
    }


    @RequestMapping("/add/do")
    @ResponseBody
    public R add(Notice notice){
        return service.add(notice);
    }

    @GetMapping("/findout/page")
    public String findoutPage(Integer noticeId, Model model){
        model.addAttribute("noticeId", noticeId);
        return "notice/notice_findout";
    }

    @PostMapping("/change/status")
    @ResponseBody
    public LayR  listData(Notice notice){
        return service.changeStatus(notice);
    }

    @PostMapping("/delete")
    @ResponseBody
    public R delete(@RequestParam("ids[]") String[] ids){
        return service.deleteAll(ids);
    }

    @PostMapping("/deleteid")
    @ResponseBody
    public R deleteid(Integer noticeId){
        return service.deletid(noticeId);
    }

    @PostMapping("/details")
    @ResponseBody
    public R details(Integer noticeId){
        return service.details(noticeId);
    }



}
